<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
<head>
    <meta charset="UTF-8"/>
    <title>Title</title>
    <!-- load css -->

    <link rel="stylesheet" type="text/css" th:href="@{/plugin/layui/css/font/iconfont.css}" media="all"/>
    <link rel="stylesheet" type="text/css" th:href="@{/plugin/layui/js/layui/css/layui.css}"  media="all"/>
    <link rel="stylesheet" type="text/css" th:href="@{/css/main.css}"  media="all"/>
<style>

</style>
</head>
<body>
<div class="layui-fluid larry-wrapper">
    <div class="layui-row layui-col-space30">
        <div class="layui-col-xs24">
            <section class="panel panel-padding">
                <form id="form1" class="layui-form layui-form-pane" action="">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">验证手机</label>
                            <div class="layui-input-inline">
                                <!--<input type="tel" name="phone" lay-verify="required|phone" autocomplete="off" class="layui-input"/>-->
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">验证邮箱</label>
                            <div class="layui-input-inline">
                                <!--<input type="text" name="email" lay-verify="email" autocomplete="off" class="layui-input"/>-->
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">帐号</label>
                        <div class="layui-input-block">
                            <input type="text" name="userAccount" required="required" jq-verify="required" jq-error="请输入帐号" placeholder="请输入帐号" autocomplete="off" class="layui-input "/>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">密码</label>
                        <div class="layui-input-block">
                            <input type="password" name="userPassword" placeholder="密码" autocomplete="off" class="layui-input "/>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">密码确认</label>
                        <div class="layui-input-block">
                            <input type="password" name="pwd2" placeholder="密码确认" autocomplete="off" class="layui-input "/>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">所属角色</label>
                        <div class="layui-input-inline">
                            <select name="role">
                                <option value="1">管理员</option>
                                <option value="2">客服</option>
                                <option value="3">运营</option>
                            </select>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">姓名</label>
                        <div class="layui-input-block">
                            <input type="text" name="title" placeholder="姓名" autocomplete="off" class="layui-input "/>
                        </div>
                    </div>
                    <div class="layui-form-item" pane="pane">
                        <label class="layui-form-label">性别</label>
                        <div class="layui-input-inline">
                            <input type="radio" name="sex" title="男" value="1" checked="checked" />
                            <input type="radio" name="sex" title="女" value="0" />
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">手机</label>
                        <div class="layui-input-block">
                            <input type="text" name="title" placeholder="手机号码" autocomplete="off" class="layui-input "/>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">邮箱</label>
                        <div class="layui-input-block">
                            <input type="text" name="title" placeholder="邮箱" autocomplete="off" class="layui-input "/>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">部门</label>
                        <div class="layui-input-block">
                            <input type="text" name="title" placeholder="部门" autocomplete="off" class="layui-input "/>
                        </div>
                    </div>
                    <div class="layui-form-item" pane="pane">
                        <label class="layui-form-label">状态</label>
                        <div class="layui-input-inline">
                            <input type="radio" name="status" title="启用" value="1" checked="checked" />
                            <input type="radio" name="status" title="禁用" value="0" />
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" jq-filter="submit" lay-submit="" lay-filter="addUser">立即提交</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>
                </form>
            </section>
        </div>
    </div>
</div>
</body>
<script type="text/javascript" th:src="@{/plugin/layui/js/layui/layui.js}"></script>
<script type="text/javascript" th:src="@{/plugin/layui/js/version.js}"></script>
<script th:src="@{/plugin/layui/js/common.js}"></script>

<script>
    layui.use(['myform','zzpUtils','form'],function () {
        var form = layui.form,
        zzpUtils = layui.zzpUtils;
        form.on("submit(addUser)",function(data){
            zzpUtils.confirm("是否确定添加",function(index){
            zzpUtils.action({
                url:"/userLogin/userLogin",
                data:JSON.stringify(data.field),
                success:function (data) {
                    setTimeout(function(){
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                        top.layer.msg("用户添加成功！");
                        //刷新父页面
                        parent.location.reload();
                    },500);
                },error: function (xhr, textStatus) {
                    console.log(textStatus);
                    console.log(xhr)
                }
            })
            })
            return false;

        });
    });
</script>
</html>